package Controller.Member;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;
import org.springframework.web.servlet.mvc.Controller;

import Bean.MemberBean;
import Dao.MemberDao;


public class MemberUpdate extends AbstractCommandController{
	private MemberDao member;
	
	public void setMember(MemberDao member) {
		this.member = member;
	}

	@Override
	protected ModelAndView handle(HttpServletRequest req,
			HttpServletResponse res, Object obj, BindException arg3)
			throws Exception {
		res.setCharacterEncoding("UTF-8");
		
		MemberBean bean = (MemberBean)obj;
		
		System.out.println();
		System.out.println(" Request 출력결과 내본것 ");
		System.out.println(req.getParameter("m_id"));
		System.out.println(req.getParameter("m_pw"));
		System.out.println(req.getParameter("m_nickname"));
		System.out.println(req.getParameter("m_email"));
		System.out.println(req.getParameter("m_ssn1"));
		System.out.println(req.getParameter("m_ssn2"));
		System.out.println(req.getParameter("m_addres"));
		System.out.println();
		System.out.println(" Object 출력결과 내본것 ");
		System.out.println(bean.getM_id());
		System.out.println(bean.getM_pw());
		System.out.println(bean.getM_nickname());
		System.out.println(bean.getM_email());
		System.out.println(bean.getM_ssn1());
		System.out.println(bean.getM_ssn2());
		System.out.println(bean.getM_addres());
		
		member.mUpdate(bean);
		ModelAndView mav = new ModelAndView();
		mav.setViewName("redirect:/home.main");
		return mav;
		
	}
}
